from collections import defaultdict, deque

# 请在此输入您的代码
A = list(input())
B = list(input())
A = deque(A)
B = deque(B)

table = []  # 桌上的牌堆
curr_user = 0  # 现在出牌的角色
table_card_index = defaultdict()  # 桌上某张牌的索引+1
while len(A) and len(B):
    # 当前角色放牌
    if curr_user == 0:  # A
        card = A.popleft()
    else:
        card = B.popleft()

    table.append(card)
    # 若桌上有相同类型的牌
    if card in table_card_index and table_card_index[card] != 0:
        while len(table) >= table_card_index[card]:
            # 当前角色拿走所有牌
            top_ = table.pop()
            if top_ != card: table_card_index[top_] = 0
            if curr_user == 0:
                A.append(top_)
            else:
                B.append(top_)
        table_card_index[card] = 0
    else:
        table_card_index[card] = len(table)
        curr_user = (curr_user + 1) % 2

if len(A):
    print("".join(A))
elif len(B):
    print("".join(B))
